package training;

import java.util.Scanner;

public class Day3_02 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[] arr = new int[]{1,2,3,2,1,2,2};
        int result = arr[0];
        int times = 1;
        for (int i = 1; i < arr.length; i++) {
            if(times != 0) {
                if (arr[i] != result) {
                    times--;
                } else {
                    times++;
                }
            } else {
                result = arr[i];
                times = 1;
            }
        }
        int count = 0;
        for (int i = 0; i < arr.length; i++) {
            if(result == arr[i]){
                count++;
            }
        }
        System.out.println(count > arr.length/2 ? result : 0);
    }
}
